package org.django4j;

import javax.servlet.http.HttpServletResponse;

/**
 * convert a model to xml string (castor?)
 */
public class XmlView implements View{
    /** when mode is null, the http response body will be blank */ 
    private Object model;   
    private int statusCode = HttpServletResponse.SC_OK; // http status code
    
    public XmlView(){}
    
    public XmlView(int statusCode){
        this.statusCode = statusCode;
    }
    
    public XmlView(Object model){
        this.model = model;
    }
    
    public XmlView(Object model, int statusCode){
        this.model = model;
        this.statusCode = statusCode;
    }
    
    public Object getModel(){
        return this.model;
    }
    
    public String getView() {
        return (this.model == null)?"":this.model.toString();
    }

    public int getStatusCode(){
        return this.statusCode;
    }
    
    public String getViewType(){
        return View.TYPE_XML;
    }
}
